﻿using System;
using VsxFactory.Modeling.VisualStudio;

namespace VsxFactory.Modeling.Strategies.VisualStudio
{
    class VSReference : IVsProjectReference
    {
        private Guid projectGuid = Guid.Empty;
        private string assemblyReference;
        private string version;
        private IVsSolution solution;

        public VSReference(IVsSolution solution, HierarchyNode node)
        {
            System.Diagnostics.Contracts.Contract.Requires(solution != null);
            System.Diagnostics.Contracts.Contract.Requires(node != null);

            this.solution = solution;
        }

        public VSReference(IVsSolution solution, Guid projectGuid)
        {
            System.Diagnostics.Contracts.Contract.Requires(solution != null);
            System.Diagnostics.Contracts.Contract.Requires(projectGuid != Guid.Empty);
            
            this.solution = solution;
            this.projectGuid = projectGuid;
        }

        public VSReference(IVsSolution solution, string assemblyName, string version)
        {
            System.Diagnostics.Contracts.Contract.Requires(!String.IsNullOrWhiteSpace(assemblyName));
            System.Diagnostics.Contracts.Contract.Requires(solution != null);

            this.solution = solution;
            assemblyReference = assemblyName;
            this.version = version;
        }

        public string Assembly
        {
            get { return assemblyReference; }
        }

        public bool IsProjectReference
        {
            get { return projectGuid != Guid.Empty; }
        }

        public object ExternalObject
        {
            get { return null; }
        }

        public IVsSolution Solution
        {
            get { return solution; }
        }


        public Guid ProjectGuid
        {
            get { return projectGuid; }
        }

        public string Version
        {
            get { return version; }
        }

        public string Path
        {
            get { return assemblyReference; }
        }
    }
}
